#include "pch.h"
#include <tchar.h>
#include <stdio.h>
#include <windows.h>
#include <locale.h>
#include "WinRarConfig.hpp"
#include "WinRarKeygen.hpp"
#include <system_error>
#include "WinRarKeygenDll.h"

const char* generate_register_info(const char* lpszUserName, const char* lpszLicenseType) {
    setlocale(LC_ALL, "");
    try {
#if defined(_UNICODE) || defined(UNICODE)
        WinRarKeygen<WinRarConfig>::RegisterInfo lic = WinRarKeygen<WinRarConfig>::GenerateRegisterInfo(lpszUserName, lpszLicenseType);
#else
        WinRarKeygen<WinRarConfig>::RegisterInfo lic = WinRarKeygen<WinRarConfig>::GenerateRegisterInfo(lpszUserName, lpszLicenseType);
#endif
        std::string head = "RAR registration data";
        return _strdup((head + "\r\n" + lic.UserName + "\r\n" + lic.LicenseType + "\r\nUID=" + lic.UID + "\r\n" + lic.HexData + "\r\n").c_str());
    }
    catch (...){
    }
    return "";
}